/**
 * 
 */
package com.rangers.auth.sample.jpa.entity;

import java.util.Set;

import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty.Access;
import com.rangers.auth.base.details.BriefUser;
import com.rangers.auth.sample.jpa.convert.SetRoleConverter;

import lombok.Data;

@Data
@Entity
@Table(name="tb_user")
public class User implements BriefUser<Role,String>{
	@Id
	@GeneratedValue(generator = "uuid")
	@GenericGenerator(name = "uuid", strategy = "uuid2")
	private String id;
	
	@NotEmpty(message = "账户名称不能为空")
	@Length(min=1,max = 64, message = "账户名称位数必须在[64]位以内")
	private String username;// 账户名

//	@NotEmpty(message = "密码不能为空")
//	@Length(min=1,max = 16, message = "密码位数必须在[16]位以内")
	@JsonProperty(access = Access.READ_ONLY)
	private String password;// 密码

	private Long scopeId;// 所属范围

	@Convert(converter = SetRoleConverter.class)
	private Set<Role> roles;// 角色集
	
	private boolean isEnabled = true;//是否可用：默认为true
}
